package cn.tedu.charging.user.dao.repository.impl;

import cn.tedu.charging.user.dao.mapper.UserMapper;
import cn.tedu.charging.user.dao.repository.UserRepository;
import cn.tedu.charging.user.pojo.po.UserPO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Slf4j
@Repository
public class UserRepositoryImpl implements UserRepository {

    @Autowired
    private UserMapper userMapper;
    @Override
    public UserPO selectUserByOpenId(String openId) {
        log.debug("UserRepositoryImpl's openId is {}",openId);
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("wx_open_id",openId);
        return userMapper.selectOne(queryWrapper);
    }
    @Override
    public Integer insert(UserPO userPO) {
        log.debug("保存之前的UserPO对象{}",userPO);
        int rows = userMapper.insert(userPO);
        log.debug("保存之后的UserPO对象{}",userPO);
        return userPO.getId();
    }
}
